From 869f300f0aefcff3b0302a9e4b7297e54f08c1dd Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Oct 2014 16:04:28 +0100 Subject: [PATCH] gdk_x11_display_make_gl_context_current: move some code This moves the code related to the frame sync code into the is_attached check, which means we don't have to ever run this when making non-window-paint contexts current. This is a minior speed thing, but the main advantage is that it makes making a non-paint context current threadsafe. --- gdk/x11/gdkglcontext-x11.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index 9c2d9a9751..4315bfd7aa 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -1152,17 +1152,6 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display, context_x11 = GDK_X11_GL_CONTEXT (context); - window = gdk_gl_context_get_window (context); - - // If the WM is compositing there is no particular need to delay - // the swap when drawing on the offscreen, rendering to the screen - // happens later anyway, and its up to the compositor to sync that - // to the vblank. - screen = gdk_window_get_screen (window); - do_frame_sync = ! gdk_screen_is_composited (screen); - - context_x11->do_frame_sync = do_frame_sync; - GDK_NOTE (OPENGL, g_print ("Making GLX context current to drawable %lu\n", (unsigned long) context_x11->drawable)); @@ -1177,6 +1166,17 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display, if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval) { + window = gdk_gl_context_get_window (context); + + /* If the WM is compositing there is no particular need to delay + * the swap when drawing on the offscreen, rendering to the screen + * happens later anyway, and its up to the compositor to sync that + * to the vblank. */ + screen = gdk_window_get_screen (window); + do_frame_sync = ! gdk_screen_is_composited (screen); + + context_x11->do_frame_sync = do_frame_sync; + if (context_x11->do_frame_sync) glXSwapIntervalSGI (1); else -- 2.30.2